﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RN.ERP.Web.ModelService;
using Newtonsoft.Json;
using System.Web.UI.HtmlControls;

namespace RN.ERP.Web.UserControl
{
    public partial class UCChangeNew : Utilities.BaseUserControl
    {
        /*
        * 1、直接通过页面url传参，2、通过属性传参
        * 传入参数:
        * 变更集ID：changeSetId
        * 变更类型：objectType（企业：1,人员：4）
        * 人员或企业主键：objectId
        * 人员或企业名称：objectName
        */
        #region 公共参数属性
        /// <summary>
        /// 变更记录ID
        /// </summary>
        public int ChangeSetId
        {
            get;
            set;
        }
        /// <summary>
        /// //变更类型(1；4；4,5,6,9,10)
        /// </summary>
        public string ObjectType
        {
            get;
            set;
        }
        /// <summary>
        /// 人员或企业等变更项主键
        /// </summary>
        public string ObjectId
        {
            get;
            set;
        }
        /// <summary>
        /// 人员或企业名称
        /// </summary>
        public string ObjectName
        {
            get;
            set;
        }
        #endregion

        #region 公共属性

        /// <summary>
        /// 企业地区
        /// </summary>
        protected string AreaCode
        {
            get
            {
                return UserInfo.AreaCode.Substring(0, 2);
            }
        }

        /// <summary>
        /// 当前市场
        /// </summary>
        protected string CurrentArea
        {
            get
            {
                return UserInfo.CurrentArea;
            }
        }

        /// <summary>
        /// 用户角色
        /// </summary>
        protected string RoleId
        {
            get
            {
                return UserInfo.RoleId;
            }
        }
        /// <summary>
        /// 当前变更纪录主键
        /// </summary>
        private string keyId
        {
            get
            {
                if (ViewState["keyId"] != null)
                {
                    return ViewState["keyId"].ToString();
                }
                ////变更项主键默认页面传递的objectID
                return hdObjectId.Value.ToString();
            }
            set
            {
                ViewState["keyId"] = value;
            }
        }

        /// <summary>
        /// 页面控件编辑状态
        /// </summary>
        protected int EditStatus;

        /// <summary>
        /// 变更子项列表
        /// </summary>
        private string ChangeRecords
        {
            get 
            {
                if (ViewState["ChangeRecord"] != null)
                {
                    return ViewState["ChangeRecord"].ToString();
                }
                return null;
            }
            set
            {
                ViewState["ChangeRecord"] = value;
            }
        }

        /// <summary>
        /// 审核状态码tb_flowCode表中的codeType
        /// </summary>
        private int ChangeType
        {
            get
            {
                int changeType = 8020;
                int.TryParse("8020" + RoleId.Trim(), out changeType);
                return changeType;
            }
        }
        #endregion
       
        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            {
                if (!IsPostBack)
                {
                    GetParams();
                    GetChangeInfo();
                    BindChangeItemDll();
                    BindChangItemsList();
                    //CheckFlowCode();
                }
            }
            //catch { }
        }

        #region 初始化设置

        /// <summary>
        /// 获取传递参数
        /// </summary>
        private void GetParams()
        {
            EditStatus = 0;//默认可编辑
            int changeSetId = 0;//变更集ID
            string objectId = string.Empty;//企业或人员等主键
            if (Request.QueryString["changeSetId"] != null)
            {
                int.TryParse(Request.QueryString["changeSetId"].Trim(), out changeSetId);
                ChangeSetId = changeSetId;
            }
            if (Request.QueryString["objectType"] != null)
            {
                ObjectType = Request.QueryString["objectType"].Trim();
            }
            if (Request.QueryString["objectId"] != null)
            {
                objectId = Request.QueryString["objectId"].Trim();
                ObjectId = objectId;
            }
            //人员或企业名称
            if (Request.QueryString["objectName"] != null)
            {
                ObjectName = Request.QueryString["objectName"].Trim();
            }
            //用户客户端取值
            hdObjectId.Value = ObjectId;
            hdObjectType.Value = ObjectType;
            hdChangeSetId.Value = ChangeSetId.ToString();
            hdObjectName.Value = ObjectName;
            hdIsrtUserId.Value = UserInfo.CorpUserGuid;
            hdIsrtUserName.Value = UserInfo.Name;

        }

        /// <summary>
        /// 状态及显示内容控制
        /// </summary>
        private void CheckFlowCode()
        {
           
            //添加变更信息
            //if (hdChangeSetId.Value.Trim() == "0")
            //{
            //    SetDefaultVal();
            //}
            //else
            //{
            //    CheckChange();
            //}
        }
        /// <summary>
        /// 页面初始化默认值
        /// </summary>
        private void SetDefaultVal()
        {
            //EditStatus = 0;//可以编辑
            //btnSaveDiv.Visible = true;//变更项添加按钮
            //btnChangeDiv.Visible = true;//上报保存按钮
            //changInfoAdd.Visible = true;//变更项添加部分
            ////企业图片上传按钮
            //corpCertBtn.Visible = true;
            //corpPsnBtn.Visible = true;
            //CorpORGBtn.Visible = true;
            //CorpSWBtn.Visible = true;
            //CorpAQBtn.Visible = true;
            //CorpStampBtn.Visible = true;
            //CorpBZJBtn.Visible = true;
          
        }
        /// <summary>
        /// 根据审核状态配置页面显示状态
        /// </summary>
        private void CheckChange()
        {
            using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
            {
                EditStatus = 1;////不可编辑
                //取得变更集可操作状态集
                List<ModelService.OperationResult> resultList = JsonConvert.DeserializeObject<List<ModelService.OperationResult>>(client.CheckChange(hdChangeSetId.Value.Trim(), RoleId, CurrentArea));
                if (resultList == null)
                {
                    return;
                }
                //可上报为真表示可编辑
                if (resultList[0].Result)
                {
                    SetDefaultVal();
                }
                //审核操作为真表示可执行审核
                if (resultList[1].Result || resultList[2].Result)
                {
                    if (UserInfo.RoleType == "Manager")
                    {
                        divOperation.Visible = true;//审核                      
                    }
                }
            }
            //操作记录
            BindDwvHistory();
        }

        /// <summary>
        /// 显示变更审核操作记录
        /// </summary>
        /// <param name="SetID"></param>
        private void BindDwvHistory()
        {
            divHistory.Visible = true;//显示日志
            using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
            {
                string result = client.AuditLogs(hdChangeSetId.Value.Trim(), CurrentArea);
                if (!string.IsNullOrWhiteSpace(result) && !result.Equals("null"))
                {
                    List<User_Log> logs = JsonConvert.DeserializeObject<List<User_Log>>(result);
                    dwvHistory.DataSource = logs;
                    dwvHistory.DataBind();
                }
            }
        }

        /// <summary>
        /// 取得变更集和变更项信息
        /// </summary>
        /// <param name="empGuid"></param>
        /// <param name="areaCode"></param>
        private void GetChangeInfo()
        {
            int setId = 0;
            if (int.TryParse(hdChangeSetId.Value.Trim(), out setId) && setId > 0)
            {
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    var result = JsonConvert.DeserializeObject<ModelService.ChangeDetail>(client.GetChangeDetailsNew(setId, CurrentArea));
                    var changeSet = result.ChangeSet;////变更集
                    ChangeRecords = JsonConvert.SerializeObject(result.ChangeInfos.ToList());////变更项列表
                }
            }
        }
        #endregion

        #region 变更项下拉列表操作

        /// <summary>
        /// 取得信息变更项
        /// </summary>
        private List<ModelService.Tb_ChangeItem> BindDDlChangeItem(int parentId)
        {
            try
            {
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    return JsonConvert.DeserializeObject<List<ModelService.Tb_ChangeItem>>(client.GetChangeItemsNew(hdObjectType.Value.Trim(), parentId, SystemID, CurrentArea));
                }
            }
            catch { return null; }
        }

        /// <summary>
        /// 绑定变更项下拉列表
        /// </summary>
        private void BindChangeItemDll()
        {
            ddlCorpChangeItem.DataSource = BindDDlChangeItem(0);
            ddlCorpChangeItem.DataTextField = "ChangeItemName";
            ddlCorpChangeItem.DataValueField = "ID";
            ddlCorpChangeItem.DataBind();
        }

        /// <summary>
        /// 变更项下拉列表选择变更项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlCorpChangeItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            ////页面复位，清空上次加载的数据
            SetDefualtValue();
            if (ddlCorpChangeItem.SelectedValue != "-1")
            {
                ////判断变更项是否包含多条记录，并显示多条待变更记录列表
                bool flag = GetChangItemsValues(ddlCorpChangeItem.SelectedValue.Trim(), hdObjectId.Value.Trim(), CurrentArea);
                if (flag)
                {
                    ////不存在多条待变更记录，绑定当前变更项或自变更项
                    BindChangItemsAdd(int.Parse(ddlCorpChangeItem.SelectedValue.Trim()));
                }
            }
        }

        /// <summary>
        /// 取得多条变更记录列表
        /// </summary>
        /// <param name="changItemId"></param>
        /// <param name="objectId"></param>
        /// <param name="areaCode"></param>
        private bool GetChangItemsValues(string changItemId, string objectId, string areaCode)
        {
            //try
            {
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    var result = JsonConvert.DeserializeObject<ModelService.OperationResult>(client.GetChangItemsValues(changItemId, objectId, CurrentArea));
                    ////参数错误
                    if (!result.Result)
                    {
                        lblMessage.Visible = true;
                        lblMessage.Text = result.Message;
                        return false;
                    }
                    ////绑定多条变更记录列表
                    if (result.ReturnValue != null)
                    {
                        Dictionary<string, string> kvs = JsonConvert.DeserializeObject<Dictionary<string, string>>(result.ReturnValue.ToString());
                        gvItemValues.DataSource = kvs;
                        gvItemValues.DataBind();
                        lblMessage.Visible = false;
                        gvItemValues.Visible = true;
                        return false;
                    }
                    return true;
                }
            }
            //catch { return false; }
        }

        /// <summary>
        /// 绑定变更项列表
        /// </summary>
        private void BindChangItemsAdd(int changItemId)
        {
            //try
            {
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    gvChangItemAdd.DataSource = JsonConvert.DeserializeObject<List<ModelService.Tb_ChangeItem>>(client.GetChangeItemsForIDNew(changItemId, CurrentArea));
                    gvChangItemAdd.DataBind();
                    gvChangItemAdd.Visible = true;
                }
            }
            //catch { }
        }

        /// <summary>
        /// 页面复位
        /// </summary>
        private void SetDefualtValue()
        {
            keyId = hdObjectId.Value.ToString();
            gvChangItemAdd.DataSource = null; 
            gvChangItemAdd.DataBind();
            gvChangItemAdd.Visible = false;
            gvItemValues.DataSource = null;
            gvItemValues.DataBind();
            gvItemValues.Visible = false;
            lblMessage.Visible = false;
            lblMessageAdd.Visible = false;
            lblMessageS.Visible = false;
        }

        #endregion

        #region 绑定变更项操作

        /// <summary>
        /// 取得变更前数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="selectColumn"></param>
        private Dictionary<string, string> FindOldValueBySelectItem(string changeItemId)
        {
            using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
            {
                string result1 = client.GetBeforeChangeValueNew(changeItemId, CurrentArea, new string[] { keyId });

                if (result1 != null)
                {
                    return JsonConvert.DeserializeObject<Dictionary<string, string>>(result1); 
                }
                return null;
            }
        }
        /// <summary>
        /// 取得变更后待选下拉列表绑定数据源
        /// </summary>
        /// <param name="context"></param>
        /// <param name="areaCode"></param>
        private Dictionary<string, string> GetSubChangeControl(string changeItemId)
        {
            using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
            {
                string result1 = client.GetBindChangeValueNew(changeItemId, CurrentArea, null);
                if (result1 != null)
                {
                    return JsonConvert.DeserializeObject<Dictionary<string, string>>(result1);
                }
                return null; 
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvChangItemAdd_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //try
                {
                    Tb_ChangeItem drv = (Tb_ChangeItem)e.Row.DataItem;////当前数据行
                    ////1、变更前值
                    Dictionary<string, string> dict = FindOldValueBySelectItem(drv.ID.ToString());
                    if (dict != null)
                    {
                        ////实际保存变更前双值的隐藏域
                        HtmlInputHidden hdChange = (HtmlInputHidden)e.Row.FindControl("hdBeforeChange");
                        HtmlInputHidden hdValue = (HtmlInputHidden)e.Row.FindControl("hdBeforeValue");
                        ////显示值
                        Label lblChange = (Label)e.Row.FindControl("lblBeforeChange");
                        if (hdChange != null)
                        {
                            lblChange.Text = dict.Values.FirstOrDefault();
                            hdChange.Value = dict.Values.FirstOrDefault();
                        }
                        if (hdValue != null)
                        {
                            hdValue.Value = dict.Keys.FirstOrDefault();
                        }
                    }

                    ////2、变更后的值
                    e.Row.FindControl("After" + drv.ClassValue.ToString()).Visible = true;////控制显示不同的用户控件
                    ////后台只绑定单个下拉列表
                    if (drv.ClassValue.ToString() == "3")
                    {
                        DropDownList dropBefore = (DropDownList)e.Row.FindControl("After3");
                        dropBefore.DataSource = GetSubChangeControl(drv.ID.ToString());
                        dropBefore.DataTextField = "value";
                        dropBefore.DataValueField = "key";
                        dropBefore.DataBind();
                    }
                }
                //catch { }
            }
        }

        #endregion

        #region 变更项添加删除操作

        /// <summary>
        /// 选择变更记录绑定变更项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBG_Click(object sender, EventArgs e)
        {
            Button btn=((Button)sender);
            keyId = btn.CommandArgument;////当前变更项主键
            ////绑定当前待变更项列表
            BindChangItemsAdd(int.Parse(ddlCorpChangeItem.SelectedValue.Trim()));
        }

        /// <summary>
        /// 临时保存变更项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvChangItemAdd_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //try
            {
                if (e.CommandName == "SaveAdd")
                {
                    ////变更项临时唯一标识
                    string changeItem = e.CommandArgument.ToString() + "_" + keyId;
                    List<Tb_ChangeRecord> records = GetChangItemsList();
                    ////取得临时变更项列表
                    if (records != null)
                    {
                        int count = records.Where(c => c.TmpID == changeItem).Count();
                        if (count > 0)
                        {
                            lblMessageAdd.Visible = true;
                            lblMessageAdd.Text = "变更项已经添加了，如需修改请先删除再重新添加！";
                            return;
                        }
                    }
                    ////取得当前行数据保存到列表中
                    int i = ((GridViewRow)((Button)e.CommandSource).NamingContainer).RowIndex;
                    var record = GetTbChangeRecord(i);
                    if (record != null)
                    {
                        records.Add(record);
                        ChangeRecords = JsonConvert.SerializeObject(records);
                        BindChangItemsList();
                    }
                }
            }
            //catch { }
        }

        /// <summary>
        /// 取得用户设置的变更项
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        private Tb_ChangeRecord GetTbChangeRecord(int i)
        {
            ////取得当前行数据
            GridViewRow row = gvChangItemAdd.Rows[i];
            HtmlInputHidden hdAfterChange = (HtmlInputHidden)row.FindControl("hdAfterChange");
            HtmlInputHidden hdAfterValue = (HtmlInputHidden)row.FindControl("hdAfterValue");
            if (string.IsNullOrEmpty(hdAfterChange.Value.Trim()) || string.IsNullOrEmpty(hdAfterValue.Value.Trim()))
            {
                lblMessageAdd.Visible = true;
                return null;
            }
            HtmlInputHidden hdChange = (HtmlInputHidden)row.FindControl("hdBeforeChange");
            HtmlInputHidden hdValue = (HtmlInputHidden)row.FindControl("hdBeforeValue");
            HtmlInputHidden hdItem= (HtmlInputHidden)row.FindControl("hdChangeItem");
            HtmlInputHidden hdType = (HtmlInputHidden)row.FindControl("hdItemType");
            ////实体赋值
            Tb_ChangeRecord record = new Tb_ChangeRecord();
            int itemType=0;
            int.TryParse(hdType.Value.Trim(), out itemType);
            record.ClassID = itemType;
            record.ChangeSetId = 0;
            record.ChangeItem = hdItem.Value.Trim();
            if (ddlCorpChangeItem.SelectedItem.Text.Trim() != row.Cells[0].Text.Trim())
            {
                record.ChangeItemName = ddlCorpChangeItem.SelectedItem.Text + row.Cells[0].Text.Trim();
            }
            else
            {
                record.ChangeItemName = row.Cells[0].Text.Trim();
            }
            record.BeforeChange = hdChange.Value.Trim();
            record.BeforeValue = hdValue.Value.Trim();
            record.AfterChange = hdAfterChange.Value.Trim();
            record.AfterValue = hdAfterValue.Value.Trim();
            record.OptDate = DateTime.Now;
            record.ObjectId = keyId;
            record.TmpID = hdItem.Value.Trim() + "_" + keyId;
            return record;
        }

        /// <summary>
        /// 绑定变更项列表
        /// </summary>
        private void BindChangItemsList()
        {
            lblMessageAdd.Visible = false;
            gvChangItemList.DataSource = GetChangItemsList();
            gvChangItemList.DataBind();
        }

        /// <summary>
        /// 取得变更项列表
        /// </summary>
        private List<Tb_ChangeRecord> GetChangItemsList()
        {
            List<Tb_ChangeRecord> records = new List<Tb_ChangeRecord>();
            ////取得临时变更项列表
            if (ChangeRecords != null)
            {
                records = JsonConvert.DeserializeObject<List<Tb_ChangeRecord>>(ChangeRecords);
            }
            return records;
        }

        /// <summary>
        /// 删除临时变更项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDel_Click(object sender, EventArgs e)
        {
            Button btn = ((Button)sender);
            string tmpId = btn.CommandArgument;////当前变更项主键
            List<Tb_ChangeRecord> records = GetChangItemsList();

            ////取得临时变更项列表，删除变更项
            if (records != null)
            {
                Tb_ChangeRecord record= records.Where(r => r.TmpID == tmpId).FirstOrDefault();
                if (record == null)
                {
                    lblMessageAdd.Visible = true;
                    lblMessageAdd.Text = "变更项不存在，无法删除！";
                    return;
                }
                records.Remove(record);
                ChangeRecords = JsonConvert.SerializeObject(records);
            }
            ////绑定更项列表
            BindChangItemsList();
        }

        #endregion
       
        #region 变更集保存上报

        /// <summary>
        /// 保存变更集
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmitSave_Click(object sender, EventArgs e)
        {
            try
            {
                lblMessageS.Visible = true;
                if (!CheckChangeSetRecord())
                {
                    return;
                }
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    string result =string.Empty;
                    var changeSet = GetChangeSetRecord();
                    ////执行添加修改事件
                    if (changeSet.Id == 0)
                    {
                        result = client.AddChangeNew(JsonConvert.SerializeObject(changeSet), ChangeRecords, ChangeType, CurrentArea);
                    }
                    else
                    {
                        result = client.EditChangeNew(JsonConvert.SerializeObject(changeSet), ChangeRecords, RoleId, ChangeType, CurrentArea);
                    }
                    ////取得返回的变更集信息
                    var record = JsonConvert.DeserializeObject<ModelService.OperationResult>(result);
                    if (record.Result && record.ReturnValue!=null)
                    {
                        changeSet=JsonConvert.DeserializeObject<ModelService.Tb_ChangeSetRecord>(record.ReturnValue.ToString());
                        hdChangeSetId.Value = changeSet.Id.ToString();
                    }
                    lblMessageS.Text = record.Message;
                }
            }
            catch { lblMessageS.Text = "保存信息时出错，请重新操作或联系管理员！"; }
        }

        /// <summary>
        /// 上报变更集
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmitPost_Click(object sender, EventArgs e)
        {
            try
            {
                lblMessageS.Visible = true;
                if (!CheckChangeSetRecord())
                {
                    return;
                }
                using (BasicService.BasicServiceClient client = new BasicService.BasicServiceClient())
                {
                    string result = string.Empty;
                    var changeSet = GetChangeSetRecord();
                    ////执行上报事件
                    result = client.SubmitChangeNew(string.Empty, JsonConvert.SerializeObject(changeSet), ChangeRecords,
                        hdIsrtUserId.Value.Trim(), hdIsrtUserName.Value.Trim(), RoleId, ChangeType, CurrentArea);
                    
                    ////取得返回的变更集信息
                    var record = JsonConvert.DeserializeObject<ModelService.OperationResult>(result);
                    if (record.Result)
                    {
                        ////上报成功关闭窗口
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "post", "<script>OpenAlertFn('" + record.Message + "', returnToParent);</script>");
                    }
                    else
                    {
                        lblMessage.Text = record.Message;
                    }
                   
                }
            }
            catch { lblMessage.Text = "上报信息时出错，请重新操作或联系管理员！"; }
        }

        /// <summary>
        /// 取得变更集信息
        /// </summary>
        /// <returns></returns>
        private ModelService.Tb_ChangeSetRecord GetChangeSetRecord()
        {
            ModelService.Tb_ChangeSetRecord record = new Tb_ChangeSetRecord();
            record.Description = txtChangeRemark.Text;
            record.IsDel = false;
            record.IsrtDate = DateTime.Now;
            record.IsrtUserId = hdIsrtUserId.Value.Trim();
            record.IsrtUserName = hdIsrtUserName.Value.Trim();
            record.ObjectId = hdObjectId.Value.Trim();
            record.ObjectName = hdObjectName.Value.Trim();
            record.ObjectType = GetObjectType();
            int changeSetId = 0;
            int.TryParse(hdChangeSetId.Value.Trim(),out changeSetId);
            record.Id = changeSetId;
            record.AppId = SystemID;
            return record;
        }

        /// <summary>
        /// 取得所有变更项的类型
        /// </summary>
        /// <returns></returns>
        private string GetObjectType()
        {
            string itemTypes = string.Empty;
            List<Tb_ChangeRecord> records = GetChangItemsList();
            if (records != null)
            {
                foreach (Tb_ChangeRecord record in records)
                {
                    if (!itemTypes.Contains(record.ClassID.ToString() + ","))
                    {
                        itemTypes += record.ClassID.ToString() + ",";
                    }
                }
            }
            if (string.IsNullOrEmpty(itemTypes))
            {
                itemTypes = hdObjectType.Value.Trim();
            }
            return itemTypes;
        }

        /// <summary>
        /// 验证变更集数据
        /// </summary>
        /// <returns></returns>
        private bool CheckChangeSetRecord()
        {
            ////判断是否添加变更项
            if (string.IsNullOrEmpty(ChangeRecords))
            {
                lblMessage.Text = "请先添加变更项信息！";
                return false;
            }
            ////判断是否上传图片
            return true;
        }
        #endregion

    }
}